using System;
using Orm;

namespace ormsamples {
	public class ListPetShopData {
		private readonly int ROW_COUNT = 100;
		public void ListData() {
			System.Console.WriteLine("Listing Pet...");
			petshop.Pet[] petshopPets = petshop.PetFactory.ListPetByQuery(null, null);
			int length = Math.Min(petshopPets.Length, ROW_COUNT);
			for (int i = 0; i < length; i++) {
				System.Console.WriteLine(petshopPets[i]);
			}
			
			System.Console.WriteLine(length + " record(s) retrieved.");
			
			System.Console.WriteLine("Listing Transaction...");
			petshop.Transaction[] petshopTransactions = petshop.TransactionFactory.ListTransactionByQuery(null, null);
			length = Math.Min(petshopTransactions.Length, ROW_COUNT);
			for (int i = 0; i < length; i++) {
				System.Console.WriteLine(petshopTransactions[i]);
			}
			
			System.Console.WriteLine(length + " record(s) retrieved.");
			
			System.Console.WriteLine("Listing Customer...");
			petshop.Customer[] petshopCustomers = petshop.CustomerFactory.ListCustomerByQuery(null, null);
			length = Math.Min(petshopCustomers.Length, ROW_COUNT);
			for (int i = 0; i < length; i++) {
				System.Console.WriteLine(petshopCustomers[i]);
			}
			
			System.Console.WriteLine(length + " record(s) retrieved.");
			
			System.Console.WriteLine("Listing Staff...");
			petshop.Staff[] petshopStaffs = petshop.StaffFactory.ListStaffByQuery(null, null);
			length = Math.Min(petshopStaffs.Length, ROW_COUNT);
			for (int i = 0; i < length; i++) {
				System.Console.WriteLine(petshopStaffs[i]);
			}
			
			System.Console.WriteLine(length + " record(s) retrieved.");
			
		}
		
		public void ListByCriteria() {
			System.Console.WriteLine("Listing Pet by Criteria...");
			petshop.PetCriteria lpetshopPetCriteria = new petshop.PetCriteria();
			// Please uncomment the follow line and fill in parameter(s) 
			//lpetshopPetCriteria.id.Eq();
			lpetshopPetCriteria.SetMaxResults(ROW_COUNT);
			petshop.Pet[] petshopPets = lpetshopPetCriteria.ListPet();
			int length =petshopPets== null ? 0 : Math.Min(petshopPets.Length, ROW_COUNT); 
			for (int i = 0; i < length; i++) {
				 System.Console.WriteLine(petshopPets[i]);
			}
			System.Console.WriteLine(length + " Pet record(s) retrieved."); 
			
			System.Console.WriteLine("Listing Transaction by Criteria...");
			petshop.TransactionCriteria lpetshopTransactionCriteria = new petshop.TransactionCriteria();
			// Please uncomment the follow line and fill in parameter(s) 
			//lpetshopTransactionCriteria.ID.Eq();
			lpetshopTransactionCriteria.SetMaxResults(ROW_COUNT);
			petshop.Transaction[] petshopTransactions = lpetshopTransactionCriteria.ListTransaction();
			length =petshopTransactions== null ? 0 : Math.Min(petshopTransactions.Length, ROW_COUNT); 
			for (int i = 0; i < length; i++) {
				 System.Console.WriteLine(petshopTransactions[i]);
			}
			System.Console.WriteLine(length + " Transaction record(s) retrieved."); 
			
			System.Console.WriteLine("Listing Customer by Criteria...");
			petshop.CustomerCriteria lpetshopCustomerCriteria = new petshop.CustomerCriteria();
			// Please uncomment the follow line and fill in parameter(s) 
			//lpetshopCustomerCriteria.ID.Eq();
			lpetshopCustomerCriteria.SetMaxResults(ROW_COUNT);
			petshop.Customer[] petshopCustomers = lpetshopCustomerCriteria.ListCustomer();
			length =petshopCustomers== null ? 0 : Math.Min(petshopCustomers.Length, ROW_COUNT); 
			for (int i = 0; i < length; i++) {
				 System.Console.WriteLine(petshopCustomers[i]);
			}
			System.Console.WriteLine(length + " Customer record(s) retrieved."); 
			
			System.Console.WriteLine("Listing Staff by Criteria...");
			petshop.StaffCriteria lpetshopStaffCriteria = new petshop.StaffCriteria();
			// Please uncomment the follow line and fill in parameter(s) 
			//lpetshopStaffCriteria.ID.Eq();
			lpetshopStaffCriteria.SetMaxResults(ROW_COUNT);
			petshop.Staff[] petshopStaffs = lpetshopStaffCriteria.ListStaff();
			length =petshopStaffs== null ? 0 : Math.Min(petshopStaffs.Length, ROW_COUNT); 
			for (int i = 0; i < length; i++) {
				 System.Console.WriteLine(petshopStaffs[i]);
			}
			System.Console.WriteLine(length + " Staff record(s) retrieved."); 
			
		}
		
		[STAThread]
		public static void Main(string[] args) {
			ListPetShopData listPetShopData = new ListPetShopData();
			try {
				listPetShopData.ListData();
//				listPetShopData.ListByCriteria();
			}
			finally {
				petshop.PetShopPersistentManager.Instance().DisposePersistentManager();
			}
			
		}
		
	}
}

